package db

import (
	"community-service/internal/app/config"
	"community-service/pkg/logger"
	"github.com/go-redis/redis"
)

func InitRedis() {
	r := config.CONFIG.Redis

	client := redis.NewClient(&redis.Options{
		Addr:     r.Addr,
		Password: r.Password,
	})

	pong, err := client.Ping().Result()
	if err != nil {
		logger.Error("redis 连接失败：%v", err)
	} else {
		config.REDISDB = client
		logger.Info("redis 连接成功：%v", pong)
	}
}
